package com.bestcem.xm.om.enums;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.ToString;

import java.util.Objects;

/**
 * 通知邮箱设置枚举类
 *
 * @author zhangfeng <feng.zhang@idiaoyan.com>
 * @version v1.0
 * @date 2021/10/26 18:14
 */
@Getter
@ToString
public enum EmailConfigTypeEnum {
    /**
     * 订单通知设置
     */
    ORDER("order", 1),
    /**
     * 发票通知设置
     */
    INVOICE("invoice", 2);

    private final String name;

    private final int index;

    EmailConfigTypeEnum(String name, int index) {
        this.name = name;
        this.index = index;
    }

    public static String getNameByIndex(Integer index) {
        if (Objects.isNull(index)) {
            return StrUtil.EMPTY;
        }
        for (EmailConfigTypeEnum type : values()) {
            if (index == type.getIndex()) {
                return type.getName();
            }
        }
        return StrUtil.EMPTY;
    }
}
